/**
 * INeuron.java
 *   Neuron Interface
 *
 * Robert McDougal
 * February 2007 - April 2007
 *
 * Changes:
 *  10 April 2007 - setPotential and getPotential use continuous time,
 *                  added Javadoc documentation, formatting
 */
import java.util.LinkedList ;

/**
 * Interface for a Neuron.
 * <p>An INeuron has rest potential of about 0, fires up to about 1.
 *
 * @author Robert McDougal
 */
public interface INeuron extends IParameters {
    /**
     * Sets the neuron's time to t.
     *
     * @param t time
     */
    public INeuron clone( ) ;
    
    /**
     * Sets the neuron's time to t.
     *
     * @param t time
     */
    public void setTime( int t ) ;
    
    /**
     *
     * @return Current simulation time.
     */
    public int getTime( ) ;
    
    /**
     *
     * @return Name of the neuron model.  (eg. Hodgkin-Huxley, etc...)
     */
    public String getName( ) ;
    
    /**
     *
     * @return Current membrane potential.
     */
    public double getPotential( ) ;
    
    /**
     *
     * @return Time of last spike.
     */
    public double lastSpike( ) ;
    
    /**
     * Calculates the membrane potential at a given time.
     *
     * @param t time
     * @return Membrane potential.
     */
    public double getPotential( double t ) ;
    
    /**
     * Calculates the membrane potential at a given time.
     *
     * @param t time
     * @return Membrane potential.
     */
    public double getPotential( int t ) ;
    
    /**
     * Sets the current membrane potential.
     *
     * @param v Membrane potential.
     */
    public void setPotential( double v ) ;
    
    /**
     * Sets the membrane potential at a given time.
     *
     * @param t time
     * @param v Membrane potential.
     */
    public void setPotential( double t , double v ) ;
    
    /**
     * Attaches a synapse to the neuron.
     *
     * @param s The synapse to add.
     */
    public void addSynapse( ISynapse s ) ;
    
    /**
     *
     * @return List of the synapses attached to the neuron.
     */
    public LinkedList <ISynapse> getSynapses( ) ;
    
    /**
     *
     * @return Number of synapses attached to the neuron.
     */
    public int getNumSynapses( ) ;
    
    /**
     *
     * @param n A pre-synaptic neuron.
     * @return Strength of the synapse from n to this.
     */
    public double getStrengthOfSynapseFrom( INeuron n ) ;

    /**
     *
     * @param n A post-synaptic neuron.
     * @return Strength of the synapse from this to n.
     */
    public double getStrengthOfSynapseTo( INeuron n ) ;
    
    
    /**
     *
     * @return The applied current on this neuron.  (<i>The current</i>, not a copy.)
     */
    public IAppliedCurrent getAppliedCurrent( ) ;
    
    /**
     * Sets the applied current.
     *
     * @param current The current to apply.
     */
    public void setAppliedCurrent( IAppliedCurrent current ) ;
    
    /**
     *
     * @param n a neuron that may or may not be connected to this neuron.
     * @return true if the neuron has a synapse from n, false if not
     */
    public boolean hasSynapseFrom( INeuron n ) ;

    /**
     *
     * @param n a neuron that may or may not be connected to this neuron.
     * @return true if the neuron has a synapse to n, false if not
     */
    public boolean hasSynapseTo( INeuron n ) ;
    
    /**
     * Advance the neuron one time step.  Does NOT advance synapses.
     */
    public void advance( ) ;
    

    /**
     * Advance all synapses that go TO this neuron by a deltaTime of 1.
     */    
    public void advanceSynapses( ) ;
    

    /**
     * Calculates the distance to neuron n.  Returns Double.POSITIVE_INFINITY
     * if n or this has no place.
     *
     * @param n a neuron
     * @return distance to n
     */
    public double dist( INeuron n ) ;


    /**
     * 
     * @return the location of the neuron.
     */    
    public Point getPlace( ) ;
    

    /**
     * Positions the neuron at p.
     *
     * @param p a location
     */    
    public void setPlace( Point p ) ;
    

    /**
     * Removes all record of previous potentials.
     * Would probably want to reset time to 0 after use.
     */
    public void clearHistory( ) ;
    

    /**
     * Returns a curve of membrane potential vs time.
     */
    public Curve getCurve( ) ;

    /**
     * Returns a curve of membrane potential vs time.
     *
     * @param startT starting time
     * @param endT ending time
     */    
    public Curve getCurve( int startT , int endT ) ;
}
